package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.dto.CldCheckTemplateDto;
import com.cleaningcloud.cld.domain.vo.CldCheckTemplateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldCheckTemplate;
import com.cleaningcloud.cld.service.ICldCheckTemplateService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 考核模版Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/checkTemplate")
public class CldCheckTemplateController extends BaseController
{
    @Autowired
    private ICldCheckTemplateService cldCheckTemplateService;

    /**
     * 查询考核模版列表
     */
    @RequiresPermissions("cld:checkTemplate:list")
    @GetMapping("/list")
    public TableDataInfo list(CldCheckTemplate cldCheckTemplate)
    {
        startPage();
        List<CldCheckTemplateVo> list = cldCheckTemplateService.selectCldCheckTemplateList(cldCheckTemplate);
        return getDataTable(list);
    }

    /**
     * 导出考核模版列表
     */
    @RequiresPermissions("cld:checkTemplate:export")
    @Log(title = "考核模版", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldCheckTemplate cldCheckTemplate)
    {
        List<CldCheckTemplateVo> list = cldCheckTemplateService.selectCldCheckTemplateList(cldCheckTemplate);
        ExcelUtil<CldCheckTemplateVo> util = new ExcelUtil<>(CldCheckTemplateVo.class);
        util.exportExcel(response, list, "考核模版数据");
    }

    /**
     * 获取考核模版详细信息
     */
    @RequiresPermissions("cld:checkTemplate:query")
    @GetMapping(value = "/{templateId}")
    public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
    {
        return success(cldCheckTemplateService.selectCldCheckTemplateByTemplateId(templateId));
    }

    /**
     * 新增考核模版
     */
    @RequiresPermissions("cld:checkTemplate:add")
    @Log(title = "考核模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldCheckTemplateDto cldCheckTemplate)
    {
        return toAjax(cldCheckTemplateService.insertCldCheckTemplate(cldCheckTemplate));
    }

    /**
     * 修改考核模版
     */
    @RequiresPermissions("cld:checkTemplate:edit")
    @Log(title = "考核模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldCheckTemplateDto cldCheckTemplate)
    {
        return toAjax(cldCheckTemplateService.updateCldCheckTemplate(cldCheckTemplate));
    }

    /**
     * 删除考核模版
     */
    @RequiresPermissions("cld:checkTemplate:remove")
    @Log(title = "考核模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{templateIds}")
    public AjaxResult remove(@PathVariable Long[] templateIds)
    {
        return toAjax(cldCheckTemplateService.deleteCldCheckTemplateByTemplateIds(templateIds));
    }

    /**
     * 查询考核模版列表
     */
    @GetMapping("/getList")
    public AjaxResult getList(CldCheckTemplate cldCheckTemplate)
    {
        List<CldCheckTemplateVo> list = cldCheckTemplateService.selectCldCheckTemplateList(cldCheckTemplate);
        return success(list);
    }

}
